<template>
    <div class='membersetting-container'>
        <navcon></navcon>
        <navsearch></navsearch>
        <div class="mc-container">
            <div class="left-container">
                <div>
                    <span>帐号管理</span>
                </div>
                <ul>
                    <li><span @click="goSecurity()">安全设置</span></li>
                    <li><span @click="goMemberData()">个人资料</span></li>
                    <li><span @click="goMyMessage()">我的消息</span></li>
                    <li><span @click="goTakeAddress()">收货地址</span></li>
                    <li><span @click="goAddProduct()">发布商品</span></li>
                    <li><span @click="goManageProduct()">商品管理</span></li>
                    <li id="myInfo">
                        <span @click="goWeiBo()">系统信息</span>
                        <div class="myInfo-tip" v-if="messagingCount > 0">{{ messagingCount }}</div>
                        <!-- <div class="myInfo-tip">22</div> -->
                    </li>
                </ul>
            </div>
            <div class="right-container">
                <div class="r-c-container">
                    <router-view></router-view>
                </div>
            </div>
        </div>
        <bottom></bottom>
    </div>
</template>

<script>
// 导入组件
import navcon from "../../components/navcon.vue"
import navsearch from "../../components/navsearch.vue"
import bottom from "../../components/navbottom.vue"
import getUUID from "../../utils/uuid"
// 导出模块
export default {
    // 模块名字
    name: 'membersetting',
    // 模块数据
    data() {
        //数据
        return {
            messagingCount: 0,   // 未读站内信条数
            messagingList: [],   // 未读站内信数据
        };
    },
    // 注册组件
    components: {
        navcon,
        navsearch,
        bottom
    },
    methods: {
        goSecurity() {
            if (window.location.href.includes("/member/membersetting/securitysetting"))
                this.$router.go(0);
            this.$router.push({ path: '/member/membersetting/securitysetting', query: { params: getUUID() } })
        },
        goMemberData() {
            if (window.location.href.includes("/member/membersetting/memberdata"))
                this.$router.go(0);
            this.$router.push({ path: '/member/membersetting/memberdata', query: { params: getUUID() } })
        },
        goTakeAddress() {
            if (window.location.href.includes("/member/membersetting/takeaddress"))
                this.$router.go(0);
            this.$router.push({ path: '/member/membersetting/takeaddress', query: { params: getUUID() } })
        }, goManageProduct() {
            if (window.location.href.includes("/member/membersetting/manageproduct"))
                this.$router.go(0);
            this.$router.push({ path: '/member/membersetting/manageproduct', query: { params: getUUID() } })
        },
        goMyMessage() {
            if (window.location.href.includes("/member/membersetting/exchange"))
                this.$router.go(0);
            this.$router.push({ path: '/member/membersetting/exchange', query: { params: getUUID() } })
        },
        goWeiBo() {
            if (window.location.href.includes("/member/membersetting/messaging"))
                this.$router.go(0);
            this.$router.push({ path: '/member/membersetting/messaging', query: { params: getUUID() } })
        },
        goAddProduct() {
            if (window.location.href.includes("/member/membersetting/addproduct"))
                this.$router.go(0);
            this.$router.push({ path: '/member/membersetting/addproduct', query: { params: getUUID() } })
        },


        /**
        * 获取未读站内行条数
        */
        getMessagingCount() {
            this.$http({
                url: this.$http.adornUrl(`/shitou-member/shitoumember/memberexchange/messagingCount?memberId=${this.memberVo.id}`),
                method: 'post',
            }).then(({ data }) => {
                if (data.code == 200) {
                    this.messagingCount = data.data
                }
            })
        },

    },
    async created() {
        let member = await this.$memberInfo()
        if (member != null) {
            this.loginValidate = true
            this.memberVo = member;
            this.getMessagingCount()
        }
    }
}
</script>
<style scoped>
@import url("../../utils/css/membersetting.css");
</style>
